package universityModel.person;

/**
 *
 * @author Parkhomenko Dima
 */
public class Name implements Cloneable {
    private String name;
    private String surname;
	
    public Name(String name, String surname) {
	this.name = name;
	this.surname = surname;
    }
	
    public Name(Name nameInParam) {
	name = nameInParam.getName();
	surname = nameInParam.getSurname();
    }
	
    public String getName() {
	return name;
    }
	
    public String getSurname() {
	return surname;
    }
	    
    @Override
    public Name clone() {
        try {
            Name cloned = (Name) super.clone();
            cloned.name = name;
            cloned.surname = surname;
            return cloned;
        } catch (CloneNotSupportedException e) {
            return null;
        }
    }
    
    @Override
    public String toString() {
	return name + " " + surname;
    }	
	
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
	}
		
        if (obj == null) {
		return false;
	}
        
	if (getClass() != obj.getClass()) {
		return false;
	}
        
        Name newName = (Name) obj;
        
        return this.name.equals(newName.getName()) && 
               this.surname.equals(newName.getSurname());
    } 
}
